<HTML>
<BODY>
<PRE>
<!-- Manpage converted by man2html 3.0.1 -->

<B><A HREF="CHDIR.html">CHDIR(2)</A></B>		  FreeBSD System Calls Manual		      <B><A HREF="CHDIR.html">CHDIR(2)</A></B>


</PRE>
<H2>NAME</H2><PRE>
     <B>chdir</B>, <B>fchdir</B> - change current working directory


</PRE>
<H2>SYNOPSIS</H2><PRE>
     <B>#include</B> <B>&lt;unistd.h&gt;</B>

     <I>int</I>
     <B>chdir</B>(<I>const</I> <I>char</I> <I>*path</I>)

     <I>int</I>
     <B>fchdir</B>(<I>int</I> <I>fd</I>)


</PRE>
<H2>DESCRIPTION</H2><PRE>
     The <I>path</I> argument points to the pathname of a directory.  The <B>chdir</B>()
     function causes the named directory to become the current working direc-
     tory, that is, the starting point for path searches of pathnames not be-
     ginning with a slash, `/'.

     The <B>fchdir</B>() function causes the directory referenced by <I>fd</I> to become the
     current working directory, the starting point for path searches of path-
     names not beginning with a slash, `/'.

     In order for a directory to become the current directory, a process must
     have execute (search) access to the directory.


</PRE>
<H2>RETURN VALUES</H2><PRE>
     Upon successful completion, a value of 0 is returned.  Otherwise, a value
     of -1 is returned and <I>errno</I> is set to indicate the error.


</PRE>
<H2>ERRORS</H2><PRE>
     <B>Chdir</B>() will fail and the current working directory will be unchanged if
     one or more of the following are true:

     [ENOTDIR]	   A component of the path prefix is not a directory.

     [ENAMETOOLONG]
		   A component of a pathname exceeded 255 characters, or an
		   entire path name exceeded 1023 characters.

     [ENOENT]	   The named directory does not exist.

     [ELOOP]	   Too many symbolic links were encountered in translating the
		   pathname.

     [EACCES]	   Search permission is denied for any component of the path
		   name.

     [EFAULT]	   <I>Path</I> points outside the process's allocated address space.

     [EIO]	   An I/O error occurred while reading from or writing to the
		   file system.

     <B>Fchdir</B>() will fail and the current working directory will be unchanged if
     one or more of the following are true:

     [EACCES]	   Search permission is denied for the directory referenced by
		   the file descriptor.

     [ENOTDIR]	   The file descriptor does not reference a directory.

     [EBADF]	   The argument <I>fd</I> is not a valid file descriptor.


</PRE>
<H2>SEE ALSO</H2><PRE>
     <B><A HREF="chroot.html">chroot(2)</A></B>


</PRE>
<H2>STANDARDS</H2><PRE>
     The <B>chdir</B>() function call is expected to conform to IEEE Std1003.1-1990
     (``POSIX'').


</PRE>
<H2>HISTORY</H2><PRE>
     A <B>chdir</B>() function call appeared in Version 7 AT&amp;T UNIX.  The <B>fchdir</B>()
     function call appeared in 4.2BSD.

4th Berkeley Distribution      December 11, 1993			     2
</PRE>
<HR>
<ADDRESS>
Man(1) output converted with
<a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
</ADDRESS>
</BODY>
</HTML>
